import request from '@clients/service';
import {ResponseType} from '@typings/response';

export const fetchDemo = (name: string): Promise<ResponseType<string>> => {
    return new Promise((resolve, reject) => {
        request
            .get<ResponseType<string>>('/api/demo?name=' + name)
            .then((res) => {
                const data = res.data;
                if (data.result == 0) {
                    return resolve(data);
                } else {
                    reject(data);
                }
            })
            .catch((error) => {
                return reject(error);
            });
    });
};
